import wishApi from '@/api/wish/wish.js'
import useCreateModal from '@/hooks/useCreateModal.js'
import dialogSelf from '../tree/dialogSelf.vue'
export const columns = [
  {
    label: 'ID',
    prop: 'id',
    align: 'center',
    width: 100
    // filters: [{ text: '家', value: '家' }, { text: '公司', value: '公司' }],
    // filterMethod: (value, row) => {
    //   console.log(value, row)
    //   return 1
    // }
    // slots: {
    //   label: 'title',
    //   customRender: 'createdTime'
    // }
  },
  {
    label: '名称',
    prop: 'name',
    align: 'center',
    sortable: true,
    sortMethod: () => console.log('触发')
  },
  {
    label: '内容',
    prop: 'content',
    align: 'center'
  },
  {
    label: '时间',
    prop: 'createdTime',
    align: 'center'
  },
  {
    label: '操作',
    align: 'center',
    slots: {
      customRender: 'action'
    },
    actions: [
      {
        text: '编辑',
        type: 'button',
        props: {
          type: 'primary',
          size: 'mini'
        },
        // 权限
        permission: [1, 2],
        func: ({ row }, refreshData) => {
          console.log(111)
          useCreateModal(dialogSelf, {
            fields: row,
            callback: () => {
              refreshData()
              console.log('callback')
            }
          })
        }
      },
      {
        text: '删除', // 按钮文字
        type: 'popconfirm', // 按钮点击之后是否需要弹出气泡确认框
        // element-ui按钮的属性
        props: {
          type: 'danger',
          plain: true,
          size: 'mini'
        },
        // 权限
        permission: [1, 2],
        func: ({ row }, refreshData) => {
          wishApi.del({ id: row.id }).then(() => refreshData())
        }
      }
    ]
  }
]
